package com.hyzh.hj212.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.hyzh.hj212.config.ConfigManager;
import com.hyzh.hj212.dmo.entity.CommandEntity;
import com.hyzh.hj212.dmo.entity.SysCodeEntity;
import com.hyzh.hj212.repository.CommandRepository;
import com.hyzh.hj212.repository.SysCodeRepository;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author songkui
 * @since 2024/3/20 17:13
 */
@Service
@DS("latte")
@Slf4j
@AllArgsConstructor
public class LatteInitializeService {

    private final CommandRepository commandRepository;
    private final SysCodeRepository sysCodeRepository;

    public void initialize(){
        ConfigManager.getInstance().initCommand(listCommand());
        ConfigManager.getInstance().initSysCode(listSysCode());
    }

    private List<CommandEntity> listCommand(){
        return commandRepository.list();
    }

    private List<SysCodeEntity> listSysCode(){
        return sysCodeRepository.list();
    }



}
